<?php
//
//	file: includes/attach/class_attach_plug_ins.php
//	author: ptirhiik
//	begin: 03/02/2007
//	version: 1.6.0 - 03/02/2007
//	license: http://opensource.org/licenses/gpl-license.php GNU General Public License (GPL)
//
//	based on : attachment_mod copyright (c) 2002 Meik Sievertsen (acydburn)
//

if ( !defined('IN_PHPBB') )
{
	die('Hacking attempt');
	exit;
}

// includes/class_forum
class attach_forums extends plug_ins
{
	function auths_def(&$auths_def)
	{
		$auths_def += array(
			'auth_attachments' => array('can' => 'Rules_attach_can', 'cannot' => 'Rules_attach_cannot', 'url' => 'faq', 'parms' => array('mode' => 'attach'), 'html' => ' onclick="window.open(\'{URL}\', \'attachrules\', \'HEIGHT=450,resizable=yes,scrollbars=yes,WIDTH=700\');return false;" target="attachrules"'),
			'auth_download' => array('can' => 'Rules_download_can', 'cannot' => 'Rules_download_cannot'),
		);
		return true;
	}
}

// includes/class_topics
class attach_topics_attr extends plug_ins
{
	function attr($forum_id, $attr_id, &$data, &$res)
	{
		global $config, $user;

		if ( $data[$attr_id]['attr_field'] == 'topic_attachment' )
		{
			$res = false;
			if ( !isset($config->globals['mod_attachment_CH']['config']) || ($config->globals['mod_attachment_CH']['config'] === false) )
			{
				$config->globals['mod_attachment_CH']['config'] = new attach_config();
				$config->globals['mod_attachment_CH']['config']->read();
			}
			if ( !$config->globals['mod_attachment_CH']['config']->data['disable_mod'] && $user->auth(POST_FORUM_URL, array('auth_download', 'auth_mod'), $forum_id) )
			{
				$res = true;
				if ( empty($data[$attr_id]['attr_timg']) )
				{
					$data[$attr_id]['attr_timg'] = 'topic_attach_tiny';
				}
				if ( !isset($user->global_images[ $data[$attr_id]['attr_timg'] ]) )
				{
					$user->global_images[ $data[$attr_id]['attr_timg'] ] = $config->globals['mod_attachment_CH']['config']->data['topic_icon'];
				}
			}
		}
		return true;
	}
}

?>